var wrappedCBs = document.querySelectorAll('.wrap');

for (var i=0;i<wrappedCBs.length;(i=i+1)){
    wrappedCBs[i].onclick = cbClickHandler;
}

function cbClickHandler(e){
      var relatedCheckBox = document.querySelector('#'+this.id.substr(0,this.id.indexOf('_')));
      relatedCheckBox.checked = !relatedCheckBox.checked;
      this.className = 'wrap '+ (relatedCheckBox.checked ? 'checked' : 'unchecked');
      // report checkstate
      report('#'+this.id.substr(0,this.id.indexOf('_')) +' checked state:  '+relatedCheckBox.checked);
}

function report(str){
    document.querySelector('#report').innerHTML = str;
}